import React, { Component } from 'react'
import Fasong from "../util/events"
import PropTypes from "prop-types"
class Top extends Component {
    state = {
        activeIndex:0
    }
   static  propTypes ={
        send:PropTypes.string
    }
    componentDidMount(){
        console.log(this.props)
    }
    fn(ind){
        console.log(ind)
        this.setState({
            activeIndex:ind
        })
        Fasong.emit("zhao",ind)
    }
    render() {
        let {send} = this.props
        return (
            <div>
                {
                    send&&send.length?send.map((item,index)=>{
                        return <span key={index} onClick={this.fn.bind(this,index)} className={index==this.state.activeIndex?"active":""}>{item.tit}</span>
                    }):""
                }
            </div>
        )
    }
}

export default Top
